package com.ygqh.baby.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import com.ygqh.baby.ao.Message;
import com.ygqh.baby.interceptor.YgExceptionHandler;

public class BaseController<Entity, PK> extends YgExceptionHandler {
	// ** 错误消息 *//*
	protected static final Message ERROR_MESSAGE = Message.error("操作失败");
	// ** 成功消息 *//*
	protected static final Message SUCCESS_MESSAGE = Message.success("操作成功");


	@InitBinder
	public void initBinder(WebDataBinder binder) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		dateFormat.setLenient(false);
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); // true:允许输入空值，false:不能为空值
	}

}
